
function showC1Report() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_reportViewer") != null) {
        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_reportViewer").style.display = "block";
    }
}

function hideC1Report() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_reportViewer") != null) {
        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_reportViewer").style.display = "none";
    }
}

function showHide(elem_id) {
    // Added by 'Imran Gani' on 21-Jan-14, for toggle
    var img_src = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_imgParam").src;
    $("#ctl00_ContentPlaceHolder3_wz_Report_btnGen").toggle("fast");
    $("#" + elem_id).toggle(function () { document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_imgParam").src = (img_src.indexOf("images/collapse3.gif") > -1 ? "images/expand3.gif" : "images/collapse3.gif"); });

    // commented by 'Imran Gani' on 21-Jan-14, for toggle
    //        var btn = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_btnGen"); 
    //        if (document.getElementById(elem_id).style.display == "block")
    //        {
    //            if (btn!=null)
    //                btn.style.display = "none";
    //            document.getElementById(elem_id).style.display = "none";
    //            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_imgParam").src = "images/expand3.gif";
    //        }
    //        else
    //        {
    //            if (btn!=null)
    //                btn.style.display = "block";
    //            document.getElementById(elem_id).style.display = "block";
    //            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_imgParam").src = "images/collapse3.gif";
    //        }

    //        if ($("#" + elem_id).is(":hidden")) // Added by 'Imran Gani' on 13-Dec-12, for animation
    //        {
    //            if (btn != null)
    //                btn.style.display = "block";
    //            $("#" + elem_id).slideDown("", function () { $(this).css("display", "block"); });
    //            $("#ctl00_ContentPlaceHolder3_wz_Report_imgParam").attr("src", "Images/collapse3.gif");
    //        }
    //        else 
    //        {
    //            if (btn != null)
    //                btn.style.display = "none";
    //            $("#" + elem_id).slideUp("", function () { $(this).css("display", "none"); });
    //            $("#ctl00_ContentPlaceHolder3_wz_Report_imgParam").attr("src", "Images/expand3.gif");
    //        }
}

function validateFields() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbObjects").value == "") {
        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblFieldsMsg1").innerHTML = "Please select a table/query from the list";
        return false;
    }
    else if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lstSelectedFields1").options.length == 0) {
        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblFieldsMsg1").innerHTML = "Please select one or more fields from the list";
        return false;
    }
    return true;
}

function validateSelFields() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbObjects").value == "") {
        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblFieldsMsg1").innerHTML = "Please select a table/query from the list";
        return false;
    }
    return true;
}
    
String.prototype.endsWith = function (str)
        { return (this.match(str + "$") == str) }

$(document).ready(function() {		    
	$("a[class^=ctl00_ContentPlaceHolder3_wz_Report_StepNavigationTemplateContainerID_mnu]").click(function() {
            return validateStep3Fields();
    });
});

    function split( val ) {	return val.split( /,\s*/ );	}
        
	function extractLast( term ) { return split( term ).pop(); }
		
function setColValuesFromAjax(ddlColVal)
    {
        try
        {
            var ajaxlist=[];  
          if(ddlColVal.value != "")
          {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAjaxList").value = "";
            $.ajax({
                url: "mb_ajaxhandler.aspx?action=rpt_src_fil&data=" + ddlColVal.value + "&val=" ,
                dataType: "json",
                cache: false,
                beforeSend: function () { $('#ctl00_ContentPlaceHolder3_wz_Report_btAdd').attr('disabled', 'disabled'); },
                success: function (msg) { 
                    for (var i=0; i < msg.length; i++)
                    {
                        ajaxlist.push(msg[i]["label"]);
                    }
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAjaxList").value = JSON.stringify(msg);
                    //response(msg); 
                },
                complete: function () { $('#ctl00_ContentPlaceHolder3_wz_Report_btAdd').removeAttr('disabled'); },
                error: function (msg) { document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Select a valid column name.</div>"; }
            });
            $('#ctl00_ContentPlaceHolder3_wz_Report_txtValue').focus();
            $("#ctl00_ContentPlaceHolder3_wz_Report_txtValue").each(function(){
                $("#ctl00_ContentPlaceHolder3_wz_Report_txtValue").autocomplete({			
				    minLength: 3,
				    search: function() { // custom minLength
					    var term = extractLast( this.value );
					    if ( term.length < 3 ) { return false; }
					    return singleInput();
				    },
                    source: function( request, response ) {
                        response($.ui.autocomplete.filter( 
                            ajaxlist, extractLast(request.term)
                        ));
                    },
                    focus: function() { return false; }, // prevent value inserted on focus
                    select: function(event, ui) {
                        var terms = split( this.value );
   					    terms.pop(); // remove the current input
    					terms.push( ui.item.label ); // add the selected item
	    				terms.push( "" ); // add placeholder to get the comma-and-space at the end
		    			this.value = terms.join( ", " );
                        return false;
                    }
                });
            });
            /* Comaanded by Imran Gani on 25-Sep-2012, to skip dropdownlist for autocomplete textbox.
            $.ajax({ url: "mb_ajaxhandler.aspx" , cache:false, 
                data: "action=rpt_src_fil&data=" + ddlColVal.value,
                dataType: "json",
                beforeSend: function() { $('#btAdd').attr('disabled', 'disabled'); $('#imgLoad').show(); },
                success: function(resp) 
                {
                    if(resp != null && resp.length > 0)
                    {   
                        var fldValues = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue");
                        fldValues.options.length = 0;
                        fldValues.options[0] = new Option("--Select a Value--", "");
                        for (var i=0; i < resp.length; i++)
                        {
                            fldValues.options[i+1] = new Option(resp[i]["label"], resp[i]["value"]);
                        }
                    }
                    else
                    {
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;The selected column name does not have a value.</div>";
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue").options.length = 0;
                    }
                },
                complete: function() { $('#btAdd').removeAttr('disabled'); $('#imgLoad').hide(); },
                error: function(resp) { 
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Select a valid column name.</div>";
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue").options.length = 0; }      
            });   
            */
          }
          else
          {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Select a valid column name.</div>";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
            //document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue").options.length = 0;
          }
        }
        catch(err)
        {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;The selected column name does not have a value associated.</div>";
        }
    }
    function AddToGrid()
    {
        try
        {
            var fldName = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmdColumn_Name");
            var fldCond = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbCondition");
            var fldValues = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue"); // Added by Imran Gani on 25-Sep-2012, for autocomplete.
            //var fldValues = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue");
            //if (fldName.options[fldName.selectedIndex].value != "" && fldValues.options.length != 0 && fldValues.disabled != true)
            if (fldName.options[fldName.selectedIndex].value != "" && fldValues.disabled != true)
            {
                //if (fldValues.options[fldValues.selectedIndex].value != "")
                if (fldValues.value != "")
                {
                    var hidden = "";
                    var cid = fldName.options[fldName.selectedIndex];
                    var cond = fldCond.options[fldCond.selectedIndex]; 
                    //var val = fldValues.options[fldValues.selectedIndex]; 
                    //var hidden = "{\"fld\":\"" + cid.text + "\",\"fldid\":\"" + cid.value + "\",\"cnd\":\"" + cond.text + "\",\"cndid\":\"" + cond.value + "\",\"txt\":\"" + val.text + "\",\"val\":\"" + val.value + "\"}";
                    if (!singleInput())
                    {
                        hidden = "{\"fld\":\"" + cid.text.replace("\"", "\\\"") + "\",\"fldid\":\"" + cid.value + "\",\"cnd\":\"" + cond.text + "\",\"cndid\":\"" + cond.value + "\",\"txt\":\"" + fldValues.value.replace("\"", "\\\"") + "\",\"val\":\"" + fldValues.value.replace("\"", "\\\"") + "\"}";
                        fldValues.value = "";
                    }
                    else
                    {
                        getRelatedValues()
                        if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value != "")
                            hidden = "{\"fld\":\"" + cid.text.replace("\"", "\\\"") + "\",\"fldid\":\"" + cid.value + "\",\"cnd\":\"" + cond.text + "\",\"cndid\":\"" + cond.value + "\",\"txt\":\"" + document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value.replace("\"", "\\\"") + "\",\"val\":\"" + document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value.replace("\"", "\\\"") + "\"}";
                    }
                    if (hidden != "")
                    {
                        var hidJson = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value;
                        if (hidJson != "")
                        {
                            if (hidJson.indexOf(hidden) == -1)
                            {
                                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
                                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = hidJson + "," + hidden;
                            }
                            else
                                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;The specified expression already exists in the filter expression list.</div>";
                        }
                        else
                        {
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = hidden;
                        }
                    }
                    if (fldValues.value != "")
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;The value (" + fldValues.value + ") does not exists.</div>";
                    DisplayTable();
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value = "";
                }
                else
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Specify a valid value.</div>";
            }
            else if (fldName.options[fldName.selectedIndex].value != "" && fldValues.disabled == true)
            {
                var cid = fldName.options[fldName.selectedIndex];
                var cond = fldCond.options[fldCond.selectedIndex];
                var hidden = "{\"fld\":\"" + cid.text.replace("\"", "\\\"") + "\",\"fldid\":\"" + cid.value + "\",\"cnd\":\"" + cond.text + "\",\"cndid\":\"" + cond.value + "\",\"txt\":\"\",\"val\":\"\"}";
                var hidJson = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value;
                if (hidJson != "")
                {
                    if (hidJson.indexOf(hidden) == -1)
                    {
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = hidJson + "," + hidden;
                    }
                    else
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;The specified expression already exists in the filter expression list.</div>";
                }
                else
                {
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = hidden;
                }
                DisplayTable();
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
            }
            else
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Select a valid column name.</div>";
        }
        catch(err)
        {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Select a valid column name.</div>";
        }
    }
    function DisplayTable()
    {
        try
        {
            if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable") != null)
            {
                $('#divFilterExp').html("");
                var hidden = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value;
                if (hidden != "")
                {
                    var json = eval("([" + hidden + "])");
                    var content = "";
                    for (var i=0; i<json.length; i++)
                    {   
                        content = content + "<tr class=\"Grid_Row"+(i%2)+"\" onmouseout=\"this.className='Grid_Row"+(i%2)+"'\" onmouseover=\"this.className='Grid_Scroll_BG'\"><td><img src=\"images/Delete.gif\" title=\"Delete\" onclick=\"DeleteSourceFilter(" + i + ");\" style=\"cursor:pointer\"/></td><td>" + (1+i) + "</td><td>" + json[i]["fld"] + "</td><td>" + json[i]["cnd"] + "</td><td>" + (json[i]["txt"] == "" ? "&nbsp;" : json[i]["txt"]) + "</td></tr>";
                    }
                    content = "<table><tr style=\"width: 50px;\"><td Class=\"controlLabelFont\">Filter Expression:</td></tr><tr><td><table Class=\"NotesTable\" cellpadding=\"2\" cellspacing=\"0\"><tr class=\"pgForm_title\" style=\"font-size:11px;\"><th style=\"width:30\"></th><th style=\"width:30\">No.</th><th style=\"width:150\">Column Name</th><th style=\"width:150\">Condition</th><th style=\"width:150\">Value</th></tr>" + content + "</table></td></tr></table>"
                    $('#divFilterExp').append(content);
                    if (json.length > 1)
                    {
                        var Group = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup") != null ? document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value : "";
                        $('#divFilterExp').append("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr style=\"height: 10px;\"></tr><tr style=\"width: 50px\"><td style=\"width: 100px;\" Class=\"controlLabelFont\">Filter Grouping:</td><td style=\"width: 350px;\" ><Input type=\"text\" ID=\"txtFilterGroup\" size=\"80\" value=\"" + Group + "\" Class=\"controlFont\"/></td></tr><tr><td style=\"width: 100px;\"></td><td style=\"width: 450px; Font-Size:8pt; ForeColor:Blue;\" Class=\"defaultFont\">Please use the above textbox to apply grouping to the expression using brackets.<br>Example: (1 OR 2) AND 3</td></tr></table>");
                    }
                    else
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
                }
            }
        }
        catch(err)
        {
            $('#divFilterExp').html("");
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
        }
    }
    function DeleteSourceFilter(del)
    {
        try
        {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
            var hidden = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value;
            var json = eval("([" + hidden + "])");
            delete json[del];
            var strJson = JSON.stringify(json);
            if (strJson != "[null]")
            {
                strJson = strJson.replace("[", "").replace(",null", "").replace("null,", "").replace("]", "");
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = strJson;
                DisplayTable();
            }
            else
            {
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value = "";
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
                $('#divFilterExp').html("");
            }
        }
        catch(err)
        {}
    }
    function ConditionCheck(ddlCondVal)
    {
        try
        {
            // Modified by Imran Gani on 25-Sep-2012, for autocomplete textbox.
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value = "";
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value = "";
            if(ddlCondVal.value == "NULL" || ddlCondVal.value == "NNULL")
            {
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").disabled = true;
                $('#ctl00_ContentPlaceHolder3_wz_Report_btAdd').focus();
                //document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue").disabled = true;
            }
            else
            {
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").disabled = false;
                $('#ctl00_ContentPlaceHolder3_wz_Report_txtValue').focus();
                //document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbValue").disabled = false;    
            }
        }
        catch(err)
        {}
    }
    function validateStep3Fields()
    {
        try
        {
            if (document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable") != null && document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value != "") 
            {
                var hidden = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterTable").value;
                var json = eval("([" + hidden + "])");
                if (json.length > 1)
                {
                var logic = document.getElementById("txtFilterGroup") == null ? "" : document.getElementById("txtFilterGroup").value;
                if (logic != "" && logic.split('(').length == logic.split(')').length)
                {
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = logic;
                    logic = logic.toLowerCase().replace(/and/g, "&").replace(/or/g, "|");
                    var test = logic.match('[A-z]');
                    if (test != null && test.length > 0)
                    {
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Provide a valid filter grouping.</div>";
                        document.getElementById("txtFilterGroup").focus();
                        document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
                        return false;
                    }
                    else
                    {
                        for (var i = 1; i <= json.length; i++)
                        {
                            var r = new RegExp(i, 'g');
                            logic = logic.replace(r, "(1==1)");
                        }
                        var test = logic.match('[2-9]');
                        if (logic.endsWith("&") || logic.endsWith("|") || test != null && test.length > 0)
                        {
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Provide a valid filter grouping.</div>";
                            document.getElementById("txtFilterGroup").focus();
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
                            return false;
                        }
                    }
                }
                else
                {
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Provide a valid filter grouping.</div>";
                    document.getElementById("txtFilterGroup").focus();
                    document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfFilterGroup").value = "";
                    return false;
                }
                }            
            }
        }
        catch(err)
        {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_lblSrcFilMsg").innerHTML = "<div class=\"mbMessage\"><img id=\"imgInfo\" src=\"Images/info.gif\" alt=\"Information\" /> &nbsp;Provide a valid filter grouping.</div>";
            return false;
        }
        return true;
    }
    
    function singleInput() // Added by Imran Gani on 03-Oct-2012, for autocomplete.
    {
        try
        {
            var cond = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_cmbCondition").value;
            if (cond == "GT" || cond == "GTE" || cond == "LT" || cond == "LTE")
               return false;
            return true;
        }
        catch(e)
        {}
    }

    function getRelatedValues() // Added by Imran Gani on 03-Oct-2012, for autocomplete.
    {
        try
        {
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value = "";
            var JsonObj = eval(document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAjaxList").value);
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value = "";
            var fldText = split(document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value);
            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = "";
            if ( fldText.length > 0 && JsonObj != null && JsonObj.length > 0)
            {
                for (var i = 0; i < fldText.length; i++)
                {
                    if (fldText[i] != "")
                    {
                        var IsExit = false;
                        for (var k = 0; k < JsonObj.length; k++)
                        {
                            if (fldText[i].toLowerCase() == JsonObj[k]["label"].toString().toLowerCase())
                            {
                                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value += JsonObj[k]["id"] + "|";
                                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value += fldText[i] + ", ";
                                IsExit = true;
                                break;
                            }
                        }
                        if (!IsExit)
                        {
                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value += fldText[i] + ", ";
//                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value += fldText[i] + "|";
//                            document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value += fldText[i] + ", ";
                        }
                    }
                }
            }
            else
            {
                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value = fldText[i] ;
//                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteValue").value = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value;
//                document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_hfAutoCompleteText").value = document.getElementById("ctl00_ContentPlaceHolder3_wz_Report_txtValue").value;
            }
        }
        catch(err)
        {}
    }